//
//  RadiateKnowledgeViewController.m
//  JunZeWristband
//
//  Created by Kendama on 2017/9/7.
//  Copyright © 2017年 DT. All rights reserved.
//

#import "RadiateKnowledgeViewController.h"
#import "WebViewController.h"

@interface RadiateKnowledgeViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@property(nonatomic,strong) NSArray *dataSource;

@end

@implementation RadiateKnowledgeViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (void)dealloc
{
    
}

- (void)refreshBaseControlValue
{
    
    
}

#pragma mark - 点击事件


#pragma mark - 事件处理

#pragma mark - 代理
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSource.count;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    //    return self.dataSource.count;
    return 1;
}



- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return px1920Height(161);
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString * const cellIdentifier = @"CellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    cell.textLabel.text = self.dataSource[indexPath.row];
    cell.textLabel.textColor = [UIColor darkGrayColor];
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    //    NewsModel *news = self.dataSource[indexPath.section];
    //    if (news.url != nil) {
    //        NSString *shopLink = news.url;
    //        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:shopLink]];
    //    }
//    TabBarViewController *vc = [[TabBarViewController alloc] init];
//    [self.navigationController pushViewController:vc animated:YES];
    WebViewController *vc = [[WebViewController alloc] init];
    switch (indexPath.row) {
        case 0:
            vc.webViewType = ProgestationGuidance;
            break;
        case 1:
            vc.webViewType = ProgestationKnow;

            break;
        case 2:
            vc.webViewType = BabyGrowUp;

            break;
        case 3:
            vc.webViewType = BabyNutrition;

            break;
            
        default:
            break;
    }
    [self.navigationController pushViewController:vc animated:YES];
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}

#pragma mark - 通知处理

#pragma mark - 初始化
- (NSArray *)dataSource
{
    if(!_dataSource)
    {
        _dataSource = @[MyNSLocalizedString(@"孕前指导"),MyNSLocalizedString(@"孕前知道"),MyNSLocalizedString(@"宝宝成长"),MyNSLocalizedString(@"宝宝营养")];
    }
    return _dataSource;
}

- (UITableView *)tableView
{
    if(!_tableView)
    {
        UIView *superView = self.view;
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.backgroundColor = [UIColor whiteColor];
//        _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
//            //            [self getNewsListWithPage:1];
//        }];
        [superView addSubview:_tableView];
    }
    return _tableView;
}

- (void)setNavigationStyle
{
    [self setNavigationBarTitle:MyNSLocalizedString(@"辐射知识1")];
}

- (void)masLayoutSubview
{
    __weak UIView *superView = self.view;
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(superView).with.offset(64);
        make.left.right.equalTo(superView);
        make.bottom.equalTo(superView);
    }];
}

@end
